<?php

declare(strict_types=1);

namespace app\index\controller;

use app\common\model\Notice as NoticeModel;
use app\common\service\Util;

class Notice
{
    public function getNotice()
    {
        // 使用Notice模型获取通知列表
        $noticeModel = new NoticeModel();
        $noticeData = $noticeModel->getNoticeList();
        $noticeData = $noticeData->toArray();
        $titleData = array_column($noticeData, 'title');
        $urlData = array_column($noticeData, 'id');

        if (empty($noticeData)) {
            return Util::ajaxReturn(0, '未查询到通知', []);
        }

        return Util::ajaxReturn(1, 'OK', ['title' => $titleData, 'url' => (array)$urlData]);
    }
}
